package com.flashflexpro.flexdirector.model {
import com.flashflexpro.as3lib.EventDictionary;
import com.flashflexpro.flexdirector.constant.DirectorMetadata;


[Bindable]
[RemoteClass]
public class DtoProcedureCase extends DtoCase implements IProcedureChild{

    public function DtoProcedureCase() {
        name = "Unnamed procedure case";
        appInstId2scripts = new EventDictionary ();
        definedParamters = new EventDictionary();
        passedInParameters = new EventDictionary();
    }

    public var originProcedure:DtoTestProcedure;
    
    /**
     * who will be using this, TestCase or Procedure
     */
    public var user:IHasProcedureCaseChildren;


    public var appInstId2scripts:EventDictionary;


    /**
     * originProcedure's parameter name ----> user's parameter name
     */
    public var passedInParameters:EventDictionary;


    override public function copyInto( parent:NameAndComment, newType:Class ):NameAndComment {
        var rt:DtoProcedureCase = super.copyInto ( parent, DtoProcedureCase) as DtoProcedureCase;
        rt.originProcedure = this.originProcedure;
        rt.user = this.user;
        return rt;
    }


    override public function treeWalk(nodeFunc:Function, self:Object = null, parent:NameAndComment=null):void {
        super.treeWalk(nodeFunc, self, parent );
        originProcedure.treeWalk( nodeFunc, self, this );
    }


    public function getCodeStepType():String {
        return DirectorMetadata.metaStepTypeProcedure;
    }


    override public function destroy():void {
        user = null;
        originProcedure = null;
    }

    public function getUndefinedParams():Array{
        var rt:Array = [];
        for( var orgParamName:String in originProcedure.paramNameToUsagesMap ){
            if( passedInParameters[ orgParamName ] != null ){
                continue;
            }
            if( definedParamters[ orgParamName ] != null ){
                continue;
            }
            rt.push( orgParamName );
        }
        return rt;
    }
}
}